<template>
    <div class="listDiv">
        <div class="searchDiv">
            <el-input clearable placeholder="匹配名称" v-model="obj.req.key" class="search_key" />
            <DateRange v-model:start="obj.req.starttime" v-model:end="obj.req.endtime" sph="匹配" eph="反馈时间" />
            <el-select v-model="obj.req.state" placeholder="全部状态" class="search_select ml15" clearable>
                <el-option v-for="(item,index) in globalData.ideaStateAry" :key="index" :label="item.text" :value="item.value" />
            </el-select>
            <span class="btn search" @click="init">搜索</span>
            <span class="btn refresh" @click="obj.req.currentpage=1;init()"></span>
            <div class="searchRight">
            </div>
        </div>
        <div class="table_box"><div class="table_" id="tb">
            <ul class="head">
                <li class="mw300 mxw300">标题</li>
                <li class="mxw140">反馈人</li>
                <li class="mxw100 wcen">联系电话</li>
                <li class="">反馈图片</li>
                <li class="mw300 mxw300">内容</li>
                <li class="mw300 mxw300">回复内容</li>
                <li class="mw200 wcen">回复时间</li>
                <li class="mxw100 wcen">操作</li>
            </ul>
            <div class="body">
                <ul v-for="x in obj.ary" :key="x">
                    <li class="mw300 mxw300">
                        <el-tooltip class="box-item" effect="dark" :content="x.title" placement="top-start" :disabled="x.title.length<17">
                            <div class="lineOne pointer">{{x.title}}</div>
                        </el-tooltip>
                    </li>
                    <li class="mxw140">{{x.name}}</li>
                    <li class="mxw100 wcen">{{x.mobile}}</li>
                    <li class="">
                        <el-image v-for="(v,i) in x.imgs.split(',')" :key="i"  style="width: 35px; height: 35px" class="ml5" fit="cover" :preview-src-list="[proxy.$setting.globalUrl.fileurl+ '/idea/'+ v]" :src="proxy.$setting.globalUrl.fileurl+ '/idea/'+ v">
                            <template #error>
                                <div class="image-slot">
                                    <el-image  fit="cover" style="width: 35px; height: 35px" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"/>
                                </div>
                            </template>
                        </el-image>
                    </li>
                    <li class="mw300 mxw300">
                        <el-tooltip class="box-item" effect="dark" :content="x.msg" placement="top-start" :disabled="x.msg.length<17">
                            <div class="lineOne pointer">{{x.msg}}</div>
                        </el-tooltip>
                    </li>
                    <li class="mw300 mxw300">
                        <el-tooltip class="box-item" effect="dark" :content="x.reply" placement="top-start" :disabled="x.reply.length<17">
                            <div class="lineOne pointer">{{x.reply}}</div>
                        </el-tooltip>
                    </li>
                    <li class="mw200 wcen">{{x.replytime}} </li>
                    <li class="mxw100 wcen">
                        <DelConfirm isSlot text="回复" isclass="edit_btn" buttontype="success" :disabled="!!x.replytime" @yesClick="applyreply(x.id,obj.replymsg)">
                            <template v-slot:slot_1>
                                <div>
                                    <div class="mb5">请输入回复内容：</div>
                                    <el-input v-model="obj.replymsg" />
                                </div>
                            </template>
                        </DelConfirm>
                    </li>
                </ul>
            </div>
        </div>
        </div><Pager :value="obj.req" :init="init" />
    </div>
</template>

<script setup>
    import { reactive, getCurrentInstance, ref, toRefs, provide, computed } from 'vue'
    import DateRange from '@/components/date_range.vue'
    import DelConfirm from '@/components/del_confirm.vue'
    import Pager from '@/components/pager.vue'
    import { ElMessageBox } from 'element-plus'
    let { proxy } = getCurrentInstance()

    let obj = reactive({
        ary: [],
        req: {
            key: "",
            state:"",
            "starttime":"",
            "endtime":"",
            currentpage: 1,
            pagesize: 10,
            count: 0,
        },
        replymsg: ''
    });
    let init = () => {
        proxy.$ajax({
            url: '/idea/list',
            data: obj.req,
            bfLoading: true
        }).then(d => {
            // console.log(d)
            if(d.success){
                obj.ary = d.msg.list
                obj.req.count = d.msg.count
            }
        }).catch(() => { })
    }

    const applyreply = (id,value)=>{
        if(!value){
            proxy.elMessageMixin('请输入回复内容', 'error')
            return
        }
        // return
        proxy.$ajax({
            url: '/idea/design',
            data: { id: id , reply: value},
            bfLoading: true
        }).then(d => {
            // console.log(d)
            if(d.success){
                proxy.elMessageMixin("回复成功", 'success')
                obj.replymsg = ''
                init()
            }else{
                proxy.elMessageMixin(d.err, 'error')
            }
        }).catch(() => { })
    }
</script>

<style scoped>
    ::-webkit-scrollbar { width:10px; background-color: #FFFFFF; }
    .search_select { width:100px!important; }
    .search_key { width:160px!important; }
    #tb ul li.li2 { width: 100px; }
    #tb ul li.li3 { width: 45px; }
    #tb ul li.li4 { width: 45px; }
</style>